import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { PropsRender } from "../shopMall/PropsRender";
import { ObjCreate } from "./ObjCreate";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { ShopItemInfo } from "../../resource/info/ShopItemInfo";
import { ShopConfig } from "../../resource/ShopConfig";
import { PageSelecter } from "./pageSelect/PageSelecter";
type int = number;
//class QuickBuyListWindow
    
    export  class QuickBuyListWindow extends BaseWindow
    {
        constructor()
        {
            super();
            setSize(238, 340);
            title = Language.getString(42900);
            titleHeight = 26;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._tileList = new GTileList();
            this._tileList.x = 19;
            this._tileList.y = 39;
            this._tileList.setSize(200, 340);
            this._tileList.columnWidth = 200;
            this._tileList.rowHeight = 83;
            this._tileList.verticalScrollPolicy = ScrollPolicy.OFF;
            this._tileList.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._tileList.verticalGap = 2;
            this._tileList.setStyle("skin", flash.display.Sprite);
            this._tileList.setStyle("cellRenderer", PropsRender);
            this.addChild(this._tileList);
            this._pageSelecter = ObjCreate.createPageSelecter(75, 305, this);
            this._pageSelecter.addEventListener(flash.events.Event.CHANGE, this.onPageChange);
            return;
        }

        /* internal  */updateDataList(arg1: Array<any>): void
        {
            this._aryData = arg1;
            this._pageSelecter.currentPage = 1;
            this._pageSelecter.maxPage = Math.ceil(arg1.length / this.pageSize);
            this._tileList.dataProvider = this.getDataProvider();
            return;
        }

        /* internal  */getDataProvider(): DataProvider
        {
            var loc5=null;
            var loc1=new DataProvider();
            var loc2=(this._pageSelecter.currentPage - 1) * this.pageSize;
            var loc3=Math.min(this._pageSelecter.currentPage * this.pageSize, this._aryData.length);
            var loc4=loc2;
            while (loc4 < loc3) 
            {
                loc5 = this._aryData[loc4] as ShopItemInfo;
                loc1.addItem({"shopItemInfo": loc5});
                ++loc4;
            }
            return loc1;
        }

        /* internal  */onPageChange(arg1: Object /* flash.events.Event */): void
        {
            this._tileList.dataProvider = this.getDataProvider();
            return;
        }

        public updateData(arg1: Array<any>): void
        {
            this.updateDataList(arg1);
            return;
        }

        public quickUpdateData(arg1: int, arg2: int, arg3: int=-1, arg4: Boolean=true): void
        {
            var loc1=ShopConfig.instance.getShopItemInfoArrayByType(arg1, arg2, arg3, arg4);
            this.updateDataList(loc1);
            return;
        }

        public quickUpdateDataByJudge(arg1: Function, arg2: int=0): void
        {
            var loc1=ShopConfig.instance.getShopItemInfoArrayByJudge(arg1, arg2);
            this.updateDataList(loc1);
            return;
        }

        public static get instace(): QuickBuyListWindow
        {
            if (!QuickBuyListWindow._instance) 
            {
                QuickBuyListWindow._instance = new QuickBuyListWindow();
            }
            return QuickBuyListWindow._instance;
        }

        /* internal */ /* const */pageSize: int=3;

        public static /* const */BUYCLICK: string="点击了购买按钮";

        /* internal */ /* var */_tileList: GTileList;

        /* internal */ /* var */_pageSelecter: PageSelecter;

        /* internal */ /* var */_aryData: Array<any>;

        /* internal */ static /* var */_instance: QuickBuyListWindow;
    }
